import { Component } from '@angular/core';
import { Trip } from '../trip/trip';

import { OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { TripService } from '../trip/trip.service';

@Component({
  selector: 'my-tripcarrier',
  templateUrl: './tripcarrier.component.html'
})

export class TripCarrierComponent implements OnInit {
  ngOnInit() {
    this.getTrips();
  }

  trips: Trip[];
  selectedTrip: Trip;

  onSelect(trip: Trip) { this.selectedTrip = trip; }
  onNew() { this.selectedTrip = new Trip(); }

  constructor(
    private router: Router,
    private tripService: TripService) {
  }

  getTrips() {
    this.tripService.getTrips().then(trips => this.trips = trips);
  }
}
